<template>
	<view class="body">
		<myHeader :title="title"></myHeader>
		<view class="header">
			<view>
				  <uni-segmented-control :current="current" :values="items"  @clickItem="onClickItem" styleType="button" activeColor="#4cd964"></uni-segmented-control>
				
					<uni-search-bar @confirm="input()"
					  v-model="search"
					   @clear="search=''"
					   @cancel="cancel">
					</uni-search-bar>
				</view>
		</view>
		<view class="main">
			 <view>
			        <view class="content">
			            <view v-show="current === 0">
			                
			                <!-- 滑块内容 -->
			                <scroll-view scroll-y="true" class="scroll-Y" style="height: 400px;">
			                	<image v-if="doloadData.length===0" 
			                	 src="../../static/party_building/assets/nothing.png" mode="">
			                	</image>
			                	<uni-collapse>
			                	    <uni-collapse-item   v-for="(item,key) in doloadData" :title="item.title" >
			                	        <view style="padding: 30rpx;">
			                	          <uni-card :title="item.title" :note="item.address" :is-shadow="true"
			                	          	:extra="item.extra">
			                	          	<!-- <template v-slot:footer> -->
			                	          	<template solt="footer">
			                	          		<view class="footer-box">
			                	          			<uni-steps activeColor="#e20909" :options="item.pop" direction="column"
			                	          				:active="item.active"></uni-steps>
													<button type="default" class="mybutton" @click="gotoDetail(item,true)" size="mini">预览详情</button>
			                	          		</view>
			                	          	</template>
			                	          </uni-card>
			                	        </view>
			                	    </uni-collapse-item>
			                	</uni-collapse>
			                	
			                	<!-- 加载更多 -->
			                	<uni-load-more
			                		 @clickLoadMore="doclickLoadMore" 
			                		:status="doloadMore" :showIcon="false"
			                		iconType="auto" 
			                		:contentText="{
			                		contentdown: '点击显示更多',
			                		contentrefresh: '正在加载...',
			                		contentnomore: '没有更多数据了'}">
			                	</uni-load-more>
			                
			                </scroll-view>
			            </view>
			            <view v-show="current === 1">
			                
			                <!-- 滑块内容 -->
			                <scroll-view scroll-y="true" class="scroll-Y" style="height: 400px;">
			                	<image v-if="doneloadData.length===0" 
			                	 src="../../static/party_building/assets/nothing.png" mode="">
			                	</image>
			                	<uni-collapse>
			                	    <uni-collapse-item   v-for="(item,key) in doneloadData" :title="item.title" >
			                	        <view style="padding: 30rpx;">
			                	          <uni-card :title="item.title" :note="item.address" :is-shadow="true"
			                	          	:extra="item.extra">
			                	          	<!-- <template v-slot:footer> -->
			                	          	<template solt="footer">
			                	          		<view class="footer-box">
			                	          			<uni-steps activeColor="#e20909" :options="item.pop" direction="column"
			                	          				:active="item.active"></uni-steps>
													<button type="default" class="mybutton" @click="gotoDetail(item,false)" size="mini">预览详情</button>
														<button type="default" v-if="item.taskStatus===5" class="mybutton" @click="huizong(item.redata.meetingId)" size="mini">汇总文档</button>
												</view>
			                	          	</template>
			                	          </uni-card>
			                	        </view>
			                	    </uni-collapse-item>
			                	</uni-collapse>
			                	
			                	<!-- 加载更多 -->
			                	<uni-load-more
			                		 @clickLoadMore="doneclickLoadMore" 
			                		:status="doneloadMore" :showIcon="false"
			                		iconType="auto" 
			                		:contentText="{
			                		contentdown: '点击显示更多',
			                		contentrefresh: '正在加载...',
			                		contentnomore: '没有更多数据了'}">
			                	</uni-load-more>
			                
			                </scroll-view>
			            </view>
			        </view>
			    </view>
		</view>
	</view>
</template>

<script>
	import myHeader from '../components/head.vue'
	import {
		getGroupUser,
		addMeetingByGroup,
		checkMeetingByLeader,
		getMeetingByGroup,
		getMeetingByLeader,collectMeeting
	}
	from '../../api/api_party_meeting.js'
	export default{
		data(){
			return{
				title:"党支部负责人",
				search:'',
				current :0,
				items:["待处理","已处理"],
				doloadMore:'more',
				doneloadMore:'more',
				doParam://已处理
					{
						"current": 1,
						"pageSize": 10,
						"total":0,
						"param": {
							"meetingName": "",
							"status": "0"
						}
					},
				doneParam://已处理
					{
						"current": 1,
						"pageSize": 10,
						"total":0,
						"param": {
							"meetingName": "",
							"status": "1"
						}
					},
				doloadData: [ 
				],
				doneloadData: [  
				],
				
			}
		},components:{
			myHeader
		},created() {
			
		} ,onShow(){
			this.resetData()
		},methods:{
			onClickItem(ars) {
				this.current = ars.currentIndex
			},
			doclickLoadMore(){//待处理会议
				this.doloadMore = 'loading'
				let _this = this;
					getMeetingByLeader(
					_this.doParam
					).then(res =>{
						_this.doloadMore = 'more'
						if(res.total<_this.doParam.pageSize){
							 _this.doloadMore = 'noMore'
						}
					//处理过程
					let data = []
					
					res.records.forEach(item =>{
						let admin = item.judgeUser===null?'党支部负责人':item.judgeUser+' '+item.updateTime
						let updateTime = item.updateTime===null?'':item.updateTime
						let extra = item.meetingStatus==='1'?"会议文件待审核":item.meetingStatus==='2'?"任务进行中":item.meetingStatus==='3'?"文件已汇总":"未知状态"
						data.push({//data是最终展示数据
							address:"来源："+item.meetGroup,
							extra,
							title: item.meetingName,
							createUser:item.createUser,
							pop: [{
									title: '组长发起会议',
									desc: item.createUser+' '+item.createTime
								},
								{
									title: '会议通过',
									desc: admin
								},
								{
									title: '汇总文件',
									desc: item.endTime
								},
							],
							active:item.meetingStatus-1,//步骤
							redata:item,
						})
					})
					_this.doParam.current++;
					_this.doloadData = _this.doloadData.concat(data)
					// _this.param.pageSize = res.size
					// _this.param.total = res.total
					})
			},
			
			doneclickLoadMore(){//已经处理会议
				this.doneloadMore = 'loading'
				let _this = this;
					getMeetingByLeader(
					_this.doneParam
					).then(res =>{
						_this.doneloadMore = 'more'
						if(res.total<_this.doneParam.pageSize){
							 _this.doneloadMore = 'noMore'
						}
					//处理过程
					let data = []
					
					res.records.forEach(item =>{
						let updateTime = item.updateTime===null?'':item.updateTime
						let extra = item.meetingStatus==='1'?"会议文件待审核":item.meetingStatus==='2'?"任务进行中":item.meetingStatus==='3'?"文件已汇总":"未知状态"
						data.push({//data是最终展示数据
							address:"来源："+item.meetGroup,
							extra,
							title: item.meetingName,
							createUser:item.createUser,
							pop: [{
									title: '组长发起会议',
									desc: item.createUser+' '+item.createTime
								},
								{
									title: '会议通过',
									desc: item.judgeUser+' '+updateTime
								},
								{
									title: '汇总文件',
									desc: item.endTime
								},
							],
							active:item.meetingStatus-1,//步骤
							redata:item,
						})
					})
					_this.doneParam.current++;
					_this.doneloadData = _this.doneloadData.concat(data)
					// _this.param.pageSize = res.size
					// _this.param.total = res.total
					})
			},
			resetData(){
				
				this.doloadMore='more',
				this.doneloadMore='more',
				this.doParam={
						"current": 1,
						"pageSize": 10,
						"total":0,
						"param": {
							"meetingName": "",
							"status": "0"
						}
					},
				this.doneParam={
						"current": 1,
						"pageSize": 10,
						"total":0,
						"param": {
							"meetingName": "",
							"status": "1"
						}
					},
				this.doloadData= [ 
				],
				this.doneloadData= [  
				],
				this.doclickLoadMore()
				this.doneclickLoadMore()
			},
			cancel(){//搜索框取消
				this.doparam={
						"current": 1,
						"pageSize": 10,
						"param": {
							"meetingName": "",
							"status": "0"
						}
					},
				this.doparam={
						"current": 1,
						"pageSize": 10,
						"param": {
							"meetingName": "",
							"status": "1"
						}
					},
					this.doloadData= [];
					this.doneloadData= [];
				this.doclickLoadMore()
				this.doneclickLoadMore()
			},
			input(){//值改变
				if(this.current===0){
					this.doParam.current=1
					this.doParam.meetingName=this.search
					this.doclickLoadMore()
				}else{
					this.doneParam.current=1
					this.doneParam.meetingName=this.search
					this.doneclickLoadMore()()
				}
			
				
			},
			gotoDetail(ars,status){
				console.log(ars.redata)
				uni.navigateTo({
					url:`./directorCommit?meetingId=${ars.redata.meetingId}&status=${status}`
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	
		/**
		 * 定义按钮样式
		 */
		@mixin button-commit {
			background: linear-gradient(180deg, #ff5e59, #e20909);
			color: #fff;
		}
	.body{
		background-color: #f7f7f7;
		height: 100%;
	}
	.header{
		background-color: #fff;
		height: 200upx;
		margin-top: 5%;
		/deep/ .uni-searchbar{
			width:95%;
			margin: 0 auto 0 auto;
		}
		/deep/ .segmented-control {
			width: 90%;
			margin: 0 auto;
			border:none !important;
				.segmented-control__item{
					border-color:#e20909 !important;
					font-size: 14px !important;
					background-color: #fff !important;
					span{
						color: #e20909 !important;
					}
				}
			.segmented-control__item--button--active {
				background: #2096f3 linear-gradient(180deg,#ff5e59,#e20909);
				border: none !important;
				span{
					color: #fff !important;
				}
			}
			.segmented-control__item--button--first{
				width: 90%;
				
			}
		}
	}
	.main{
		background-color: #fff;
		width: 95%;
		margin: 5% auto 0 auto;
		height: 65%;
		.content{
			/deep/ .uni-transition{
							.uni-popup__wrapper-box{
							background-color: #FFFFFF;
							padding: 50upx;
							}
					
			}
			/deep/ .uni-card{
				margin: 0;
				uni-button{
					@include button-commit;
					margin-top: 5%;
				}
			}
		}
	}
	
</style>
